

Ext.override(Ext.data.Record, {
			set	: function(name, value) {
				if (String(this.data[name]) == String(value))
					return;

				this.dirty = true;

				if (!this.modified)
					this.modified = {};

				if (typeof this.modified[name] == 'undefined')
					this.modified[name] = this.data[name];

				this.data[name] = value;

				if (!this.editing && this.store)
					this.store.afterEdit(this, name);
			}
		});

Ext.override(Ext.data.Store, {
			// private
			afterEdit	: function(record, name) {
				if (this.modified.indexOf(record) == -1) {
					this.modified.push(record);
				};

				this.fireEvent("update", this, record, Ext.data.Record.EDIT,
						name
				);
			}
		});

Ext.override(Ext.form.BasicForm, {
	/**
	 * Returns the fields in this form as an object with key/value pairs as they would be submitted using a standard form submit.
	 * If multiple fields exist with the same name they are returned as an array.
	 * @param {Boolean} asString (optional) false to return the values as an object (defaults to returning as a string)
	 * @return {String/Object}
	*/
	getValues	: function(asString) {
		var fs = Ext.lib.Ajax.serializeForm(this.el.dom);
		if (asString === true) {
			return fs;
		}
		return Ext.urlDecode(fs.replace(/\+/g, ' ')); // /\+/g forum disabled the backslash
	},

	/**
	 * 
	 */
	reset		: function() {
		this.items.each(function(f) {
					f.reset();
				});

		this.fireEvent('reset', this);

		return this;
	}
		// ,
		// 
		// isValid : function(showError){
		// var valid = true;
		// this.items.each(function(f){
		// if(!f.isValid(showError)){
		// valid = false;
		// }
		// });
		// return valid;
		// }
	}
);

Ext.override(Ext.form.Field, {
			afterRender		: function() {
				Ext.form.Field.superclass.afterRender.call(this);
				this.initEvents();
				this.initValue();

				this.el.on("keyup", function() {
							this.fireEvent('change', this);
						}, this);
			},

			onBlur			: function() {
				this.beforeBlur();
				if (!Ext.isOpera && this.focusClass) { // don't touch in Opera
					this.el.removeClass(this.focusClass);
				}
				this.hasFocus = false;
				if (this.validationEvent !== false && this.validateOnBlur
						&& this.validationEvent != "blur") {
					this.validate();
				}
				var v = this.getValue();
				if (String(v) !== String(this.startValue)) {
					this.fireEvent('change', this, v, this.startValue);
				}
				this.fireEvent("blur", this);
			},

			getFormPanel	: function() {
				if (!this.formPanel) {
					this.formPanel = this.findParentByType('form');
				}
				return this.formPanel;
			}
		});

Ext.override(Ext.form.TextArea, {
			growPad		: -14,

			autoSize	: function() {
				if (!this.grow || !this.textSizeEl)
					return;

				var el = this.el, v = el.dom.value, ts = this.textSizeEl;

				ts.innerHTML = '';
				ts.appendChild(document.createTextNode(v));

				v = ts.innerHTML;
				Ext.fly(ts).setWidth(this.el.getWidth());

				if (v.length < 1) {
					v = "&#160;&#160;";
				} else {
					v += this.growAppend;
					if (Ext.isIE)
						v = v.replace(/\n/g, '<br />');
				};

				ts.innerHTML = v;

				var extra = ts.offsetHeight / 100 * 4;

				var h = Math.min(this.growMax, Math.max(ts.offsetHeight,
								this.growMin
						)
								+ this.growPad)
						- extra;
				if (h != this.lastHeight) {
					this.lastHeight = h;
					this.el.setHeight(h);
					this.fireEvent("autosize", this, h);
				}
			}
		});

Ext.override(Ext.form.TriggerField, {
			onResize	: function(w, h) {
				Ext.form.TriggerField.superclass.onResize.call(this, w, h);

				if (typeof w == 'number') {
					this.el.setWidth(this.adjustWidth('input', w));
				};

				this.wrap.setWidth(this.el.getWidth());
			},

			onRender	: function(ct, position) {
				Ext.form.TriggerField.superclass.onRender.call(this, ct,
						position
				);

				// Wrap the whole trigger field in a div
				this.wrap = this.el.wrap({
							cls	: "x-form-field-wrap x-trigger-field-wrap"
						});

				// Create the trigger
				this.trigger = this.wrap.createChild({
							cls	: "x-form-trigger " + this.triggerClass
						});

				// Hide the trigger on load if render
				if (this.hideTrigger) {
					this.trigger.setDisplayed(false);
				};

				this.initTrigger();

				if (!this.width) {
					this.wrap.setWidth(this.el.getWidth());
				};
			}
		});

Ext.apply(Ext.form.VTypes, {
	urlWithoutHttp	: function(v) {
		var url = /(([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
		return url.test(v);
	},

	password		: function(value, field) {
		var valid = false;

		if (field.matches) {
			var otherField = Ext.getCmp(field.matches);

			if (value == otherField.getValue()) {
				otherField.clearInvalid();
				valid = true;
			};
		};

		return valid;
	},
	passwordText	: 'Passwords do not match.',

	creditcard		: function(value, field) {
		return value.replace(/[ \-]/g, '').length == 16;
	},
	creditcardText	: 'Invalid credit card number',
	creditcardMask	: /[ \d\-]/,

	bdayyear		: function(value, field) {
		return value > (new Date().format('Y') - 14);
	}
}
);

/**
 * Overrides Ext.Shadow.prototype for custom shadows on windows
 */
Ext.apply(Ext.Shadow.prototype, {

			realign	: function(l, t, w, h) {
				if (!this.el) {
					return;
				}
				var a = this.adjusts, d = this.el.dom, s = d.style;
				var iea = 0;
				s.left = (l + a.l) + "px";
				s.top = (t + a.t) + "px";
				var sw = (w + a.w), sh = (h + a.h), sws = sw + "px", shs = sh
						+ "px";

				if (s.width != sws || s.height != shs) {
					s.width = sws;
					s.height = shs;
					if (!Ext.isIE) {
						var cn = d.childNodes;
						var sww = Math.max(0, (sw - 36)) + "px";
						cn[0].childNodes[1].style.width = sww;
						cn[1].childNodes[1].style.width = sww;
						cn[2].childNodes[1].style.width = sww;
						cn[1].style.height = Math.max(0, (sh - 36)) + "px";
					}
				}
			}

		});
